package com.hgl;

import javax.servlet.http.HttpSession;

import cn.hutool.core.util.StrUtil;

import com.hgl.exception.CodeException;

/**<pre>
 * - 常量
 * ClassName : com.teach.Const
 * Author : J.L.Zhou
 * E-Mail : 2233875735@qq.com
 * Date : 2020年8月1日 上午10:36:57
 * Version : 1.0
 * Copyright 2020 jlzhou.top Inc. All rights reserved. 
 * Warning: this content is only for internal circulation of the company. 
 * It is forbidden to divulge it or use it for other commercial purposes.
 * </pre>
 **/
public class Const {
	
	private Const(){}
	
	/**
	 * 登录用户在会话中的属性名
	 */
	public static final String LOGIN_USER_SESSION_NAME = "user";
	public static final String CODE_NAME="CODE_NAME";
	public static void  codeVerify(HttpSession session,String code){
		if(StrUtil.isEmpty(code)){
			throw new CodeException(10,"验证码不能为空");
		}
		  if(session.getAttribute(CODE_NAME)==null){      
			  throw new CodeException(11, "验证码已失效");    
			  }       
		  if(!code.equals(session.getAttribute(CODE_NAME))){      
			  throw new CodeException(12, "验证码不匹配");    
			  }  
		  }

	}


